 #导入milvusClient和DataType模块，用于连接MIilvus服务器并操作数据类型
from attr.validators import max_len
from  pymilvus import (
connections,MilvusClient,
FieldSchema,CollectionSchema,DataType,
Collection,utility
)
import random

#连接Milvus服务器
client = MilvusClient(
    uri="http://49.234.21.142:19530"
)

#第三步 查询结果
query_vector = [random.random() for _ in range(4)] #生成4个随机值

# results = client.search(
#     collection_name="book",
#     data=[query_vector], #向量
#     limit=5,
# )

# results = client.search(
#     collection_name="book",
#     data=[query_vector], #向量
#     limit=3,
#     offset=1,#从第一个开始查，查询3个
# )

# results = client.search(
#     collection_name="book",
#     data=[query_vector,[0.5] *4], #两个向量，返回4条，因为两个向量都会检索两条
#     limit=2,
# )
# print(results)


print(client.describe_collection("book")) #查询状态
